/**
 * this file will be loaded before server started
 * you can register middleware
 * https://thinkjs.org/doc/middleware.html
 */

/**
 * 
 * think.middleware('xxx', http => {
 *   
 * })
 * 
 */

import debugToolbar from 'think-debug-toolbar';

think.middleware('debug_toolbar', debugToolbar({
	panels: ['request', 'session', 'view', 'template', 'response', 'config', 'info'],
	depth: 4,
	extra_attrs: '',
	disabled: false,
	sort: false
}));


think.middleware('web_responsive', async http => {
	let userAgent = await http.userAgent();
	http.theme('pc');
	if (userAgent.match(/(iPhone|iPod|Android|ios|mobile)/i)) {
		http.theme('mobile');
	}
});